package Tree;

import java.util.ArrayList;
import java.util.List;

/**
 * 递归算法
 * 后序遍历
 */
public class PostOrderTraversal {
    public static List<Integer> solution(TreeNode root){
        List<Integer> res = new ArrayList<>();
        postOrder(root,res);
        return res;
    }

    public static void postOrder(TreeNode root,List<Integer> list){
        if(root == null){
            return;
        }
        postOrder(root.left,list);
        postOrder(root.right,list);
        list.add(root.val);
    }
}
